package com.jxwifi.cloud.quickcleanserver.main;

import android.Manifest;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.graphics.Color;
import android.net.Uri;
import android.os.Build;
import android.os.Handler;
import android.support.annotation.NonNull;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.amap.api.services.core.LatLonPoint;
import com.amap.api.services.route.BusRouteResult;
import com.amap.api.services.route.DriveRouteResult;
import com.amap.api.services.route.RidePath;
import com.amap.api.services.route.RideRouteResult;
import com.amap.api.services.route.RouteSearch;
import com.amap.api.services.route.WalkRouteResult;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.idroid.utils.ListDataSave;
import com.idroid.utils.MToast;
import com.jxwifi.cloud.quickcleanserver.R;
import com.jxwifi.cloud.quickcleanserver.adapter.MyLinearLayoutManager;
import com.jxwifi.cloud.quickcleanserver.adapter.OrderFormListAdapter;
import com.jxwifi.cloud.quickcleanserver.app.StateUtils;
import com.jxwifi.cloud.quickcleanserver.app.UrlPool;
import com.jxwifi.cloud.quickcleanserver.bean.OrderFromBean;
import com.jxwifi.cloud.quickcleanserver.bean.PoiItemBean;
import com.jxwifi.cloud.quickcleanserver.okhttp.AuzHttp;
import com.jxwifi.cloud.quickcleanserver.okhttp.DataJson_Cb;
import com.jxwifi.cloud.quickcleanserver.okhttp.Params;
import com.jxwifi.cloud.quickcleanserver.utils.AlterLocation;
import com.jxwifi.cloud.quickcleanserver.utils.Constants;
import com.jxwifi.cloud.quickcleanserver.utils.KAlertDialog;
import com.jxwifi.cloud.quickcleanserver.utils.LazyLoadFragment;
import com.jxwifi.cloud.quickcleanserver.utils.LocationGaoDe;
import com.jxwifi.cloud.quickcleanserver.utils.ToastUtils;
import com.jxwifi.cloud.quickcleanserver.workmap.MapSearchActivity;
import com.jxwifi.cloud.quickcleanserver.workmap.MapWorkActivity;
import com.view.SuperSwipeRefreshLayout;

import org.simple.eventbus.Subscriber;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.OnClick;

/**
 * 周边订单与市内订单
 * Created by Administrator on 2019/5/13.
 */

public class OrderFormFragment extends LazyLoadFragment implements RouteSearch.OnRouteSearchListener{

    private String TAG = this.getClass().getSimpleName();
    public static int PAGE_SIZE = 10;

    @Bind(R.id.img_order_from_head_images)
    ImageView mImgOrderFromHeadImages;//顶部标题图片
    @Bind(R.id.tv_order_form_periphery)
    TextView mTvOrderFromPeriphery;//周边订单
    @Bind(R.id.tv_order_form_periphery_view)
    View mTvOrderFromPeripheryView;//周边订单下划线
    @Bind(R.id.tv_order_form_inside_city)
    TextView mTvOrderFromInsideCity;//市内订单
    @Bind(R.id.tv_order_form_inside_city_view)
    View mTvOrderFromInsideCityView;//市内订单下划线
    @Bind(R.id.srl_fg_order_form_list)
    SuperSwipeRefreshLayout mSrlFgOrderFormList;
    @Bind(R.id.rv_order_form_list)
    RecyclerView mRvOrderFromList;
    @Bind(R.id.tv_order_form_location)
    TextView mTvOrderFormLocation;//

    private List<OrderFromBean> mrecords;
    private OrderFormListAdapter mAdapter;
    private int mPageIndex = 1;//页数
    private int mTotalNum;//记录接口中的总条数（如果没有返回这个字段也可以不适用）
    private boolean isErr = true;

    private int mTypeStatus = 1;//1表示周边，2表示市内
    private int mCurrentCounter;//获取的数据个数
    private boolean mNoData = true;
    private View notDataView;

    private boolean mIsMapGaoDe = true;//用于在onResume()方法中刷新lazyLoad()的判断，在地图页面返回的时候，不在onResume中刷新
    private boolean mIsRefreshing = true;//在点击周边与市内的时候，不让setRefreshing方法操作

    private ListDataSave dataSave;//用于保存位置信息，只有在APP第一次启动的时候保存一次，还有就是在选择地图回调的地方替换数据。其他地方不用到这个方法
    private static String QR_LOCATION = "QR_LOCATION";
    private List<PoiItemBean> mListBean;

    private ProgressBar progressBar;
    private TextView textView;
    private ImageView imageView;

    private boolean mIslazy=false;
    public RouteSearch  mRouteSearch;
    int mrecordsPosition;
    private boolean isVisiableOrder;

    public int setContentView() {
        dataSave = new ListDataSave(mBaseContext, QR_LOCATION);
        return R.layout.fragment_order_form;
    }

    @Override
    protected void lazyLoad() {
        if(mIslazy){
            initView();
            mAdapter.setEmptyView(R.layout.loading_view, (ViewGroup) mRvOrderFromList.getParent());
            Refresh();
            Log.w("oushuhua", "lazyLoad ==  ");
        }else{
            mIslazy=true;
        }
    }

    @Override
    protected void stopLoad() {
        Log.w("oushuhua", "OrderFormFragment" + "已经对用户不可见，可以停止加载数据");
    }

    @OnClick({R.id.tv_order_form_periphery, R.id.tv_order_form_inside_city, R.id.tv_order_form_location})
    void clickCK(View v) {
        switch (v.getId()) {
            //周边订单
            case R.id.tv_order_form_periphery:
                if (mTypeStatus == 1) {
                    return;
                }
                mTvOrderFromPeriphery.setTextColor(Color.parseColor("#3DB64D"));
                mTvOrderFromPeripheryView.setVisibility(View.VISIBLE);
                mTvOrderFromInsideCity.setTextColor(Color.parseColor("#999999"));
                mTvOrderFromInsideCityView.setVisibility(View.GONE);
                mTypeStatus = 1;
                mIsRefreshing = false;
                mNoData = true;
                isErr = true;
                lazyLoad();

                break;
            //市内订单
            case R.id.tv_order_form_inside_city:
                if (mTypeStatus == 2) {
                    return;
                }
                mTvOrderFromPeriphery.setTextColor(Color.parseColor("#999999"));
                mTvOrderFromPeripheryView.setVisibility(View.GONE);
                mTvOrderFromInsideCity.setTextColor(Color.parseColor("#3DB64D"));
                mTvOrderFromInsideCityView.setVisibility(View.VISIBLE);
                mTypeStatus = 2;
                mIsRefreshing = false;
                mNoData = true;
                isErr = true;
                lazyLoad();

                break;
            case R.id.tv_order_form_location:
                if (isPermissionGranted(Manifest.permission.ACCESS_COARSE_LOCATION,
                        Constants.QUEST_CODE_LOCTION)) {
                    Intent intent = new Intent();
                    intent.setClass(mBaseContext, MapSearchActivity.class);
                    startActivity(intent);
                } else {
                    if (Build.VERSION.SDK_INT <= 22) {
                        final KAlertDialog dialog = new KAlertDialog(mBaseContext, "定位权限已关闭\", \"定位权限已被禁止，请在设置中开启");
                        dialog.setRightTxt("去查看", new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                //前往应用详情界面
                                try {
                                    Uri packUri = Uri.parse("package:" + mBaseContext.getPackageName());
                                    Intent intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS, packUri);
                                    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                                    startActivity(intent);
                                } catch (Exception e) {
                                    MToast.shortToast(mBaseContext, "跳转失败");
                                }
                                dialog.dismiss();
                            }
                        });
                        dialog.setLeftTxt("取消", new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                dialog.dismiss();
                            }
                        });
                        dialog.show();
                    }
                }
                break;
        }
    }

    private void initView() {
        if (TextUtils.isEmpty(LocationGaoDe.getAddress())) {
            mTvOrderFormLocation.setText("定位失败");
        } else {
            SharedPreferences sharedPreferences = mBaseContext.getSharedPreferences(QR_LOCATION,
                    Activity.MODE_PRIVATE);
            String strJson = sharedPreferences.getString(QR_LOCATION, null);
            mListBean = JSON.parseArray(strJson, PoiItemBean.class);
            if (mListBean == null) {
                List<PoiItemBean> mBean = new ArrayList<PoiItemBean>();
                PoiItemBean headBean = new PoiItemBean();
                headBean.setLatitude(LocationGaoDe.getLatitude());
                headBean.setLongitude(LocationGaoDe.getLongitude());
                headBean.setCitycode(LocationGaoDe.getCityCode());
                headBean.setTitle(LocationGaoDe.getAddress());
                //Log.i(TAG,"获取定位信息 getCityCode = "+LocationGaoDe.getCityCode()+" Add = "+LocationGaoDe.getAddress());
                mBean.add(headBean);
                dataSave.setDataList(QR_LOCATION, mBean);//保存数据
                mTvOrderFormLocation.setText(LocationGaoDe.getAddress());
                mListBean = mBean;
                cleaningLocation(LocationGaoDe.getLatitude(),LocationGaoDe.getLongitude());
            } else {
                mTvOrderFormLocation.setText(mListBean.get(0).getTitle());
                cleaningLocation(mListBean.get(0).getLatitude(),mListBean.get(0).getLongitude());
            }
        }
        mRvOrderFromList.setLayoutManager(new MyLinearLayoutManager(mBaseContext, LinearLayoutManager.VERTICAL, false));
        mRvOrderFromList.setAdapter(mAdapter = new OrderFormListAdapter(R.layout.list_order_from_list_item));
        mAdapter.openLoadAnimation(BaseQuickAdapter.FOOTER_VIEW);
        //上拉加载更多操作
        mAdapter.setOnLoadMoreListener(new BaseQuickAdapter.RequestLoadMoreListener() {
            @Override
            public void onLoadMoreRequested() {
                mRvOrderFromList.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        if (mCurrentCounter >= mTotalNum) {
                            //数据全部加载完毕
                            mAdapter.loadMoreEnd();
                        } else {
                            if (isErr) {
                                onLoadMore();
                                //成功获取更多数据
                                mCurrentCounter = mAdapter.getData().size();
                                mAdapter.loadMoreComplete();
                            } else {
                                //获取更多数据失败
                                isErr = true;
                                Toast.makeText(mBaseContext, "获取更多数据失败", Toast.LENGTH_LONG).show();
                                mAdapter.loadMoreFail();
                            }
                        }
                    }
                }, 1000);
            }
        }, mRvOrderFromList);
        notDataView = getLayoutInflater().inflate(R.layout.null_layout, (ViewGroup) mRvOrderFromList.getParent(), false);
        notDataView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mNoData = true;
                isErr = true;
                mAdapter.setEmptyView(R.layout.loading_view, (ViewGroup) mRvOrderFromList.getParent());
                Refresh();
            }
        });
        mAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                if (isPermissionGranted(Manifest.permission.ACCESS_COARSE_LOCATION,
                        Constants.QUEST_CODE_LOCTION)) {
                    Intent intent = new Intent();
                    intent.setClass(mBaseContext, MapWorkActivity.class);
                    intent.putExtra("order_code", mrecords.get(position).getOrderCode());
                    intent.putExtra("rideDistance", mrecords.get(position).getRideDistance());
                    startActivity(intent);
                } else {
                    Permiss();
                }
            }
        });
        mSrlFgOrderFormList.setHeaderView(createHeaderView());
        mSrlFgOrderFormList.setOnPullRefreshListener(new SuperSwipeRefreshLayout.OnPullRefreshListener() {

            @Override
            public void onRefresh() {
                textView.setText("正在刷新");
                imageView.setVisibility(View.GONE);
                progressBar.setVisibility(View.VISIBLE);
                new Handler().postDelayed(new Runnable() {

                    @Override
                    public void run() {
                        mSrlFgOrderFormList.setRefreshing(false);
                        progressBar.setVisibility(View.GONE);
                        mPageIndex = 1;
                        getList(mTypeStatus);
                    }
                }, 1000);
            }

            @Override
            public void onPullDistance(int distance) {
                // pull distance
            }

            @Override
            public void onPullEnable(boolean enable) {
                textView.setText(enable ? "松开刷新" : "下拉刷新");
                imageView.setVisibility(View.VISIBLE);
                imageView.setRotation(enable ? 180 : 0);
            }
        });
    }

    private View createHeaderView() {
        View headerView = LayoutInflater.from(mSrlFgOrderFormList.getContext())
                .inflate(R.layout.layout_head, null);
        progressBar = (ProgressBar) headerView.findViewById(R.id.pb_view);
        textView = (TextView) headerView.findViewById(R.id.text_view);
        textView.setText("下拉刷新");
        imageView = (ImageView) headerView.findViewById(R.id.image_view);
        imageView.setVisibility(View.VISIBLE);
        imageView.setImageResource(R.drawable.down_arrow);
        progressBar.setVisibility(View.GONE);
        return headerView;
    }

    public void Refresh() {
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                Log.w("oushuhua", "mNoData ==  " + mNoData);
                if (mNoData) {
                    mPageIndex = 1;
                    getList(mTypeStatus);
                } else {
                    mAdapter.setEmptyView(notDataView);
                }
            }
        }, 1000);
    }

    public void onLoadMore() {
        getList(mTypeStatus);
    }

    public void Permiss() {
        if (Build.VERSION.SDK_INT <= 22) {
            final KAlertDialog dialog = new KAlertDialog(mBaseContext, "定位权限已关闭\", \"定位权限已被禁止，请在设置中开启");
            dialog.setRightTxt("去查看", new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    //前往应用详情界面
                    try {
                        Uri packUri = Uri.parse("package:" + mBaseContext.getPackageName());
                        Intent intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS, packUri);
                        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                        startActivity(intent);
                    } catch (Exception e) {
                        MToast.shortToast(mBaseContext, "跳转失败");
                    }
                    dialog.dismiss();
                }
            });
            dialog.setLeftTxt("取消", new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    dialog.dismiss();
                }
            });
            dialog.show();
        }
    }

    //接口请求 //status:1表示周边，2表示市内
    public void getList(final int status) {
        if(!isVisiableOrder){
            return;
        }
        if (LocationGaoDe.getLatitude() == 0.0) {
            mAdapter.setEmptyView(notDataView);
            return;
        }
        if (mListBean == null) {
            mAdapter.setEmptyView(notDataView);
            return;
        }
        if (mIsRefreshing) {

        } else {
            mIsRefreshing = true;
        }
        Params params = new Params();
        params.add("lat", mListBean.get(0).getLatitude());
        params.add("lon", mListBean.get(0).getLongitude());
        params.add("limit", 10);
        params.add("page", mPageIndex);
        String mUrlpool;
        if (status == 1) {
            mUrlpool = UrlPool.POST_ORDER_LIST;
        } else {
            mUrlpool = UrlPool.POST_ORDER_LIST_CITY;
            params.add("cityCode", mListBean.get(0).getCitycode());
        }
        AuzHttp.post(mUrlpool, params, new DataJson_Cb() {
            @Override
            public void onSuccess(int code, String data) {
                if (code == 0) {
                    JSONObject obj = JSON.parseObject(data);
                    String str = obj.getString("records");
                    mTotalNum = obj.getInteger("total");
                    mrecords = JSON.parseArray(str, OrderFromBean.class);
                    Log.i(TAG,"getList ==> mrecords.size() = "+mrecords.size());
                    setRideData(mrecordsPosition);
                    /*if (mPageIndex == 1) {
                        setData(true, mrecords);
                    } else {
                        setData(false, mrecords);
                    }*/
                }else{
                    mAdapter.setEmptyView(notDataView);
                }
            }

            @Override
            public void onFailure(int errorCode, String msg) {
                isErr = false;
                mAdapter.setEmptyView(notDataView);
                Toast toast = Toast.makeText(mBaseContext, msg, Toast.LENGTH_SHORT);
                ToastUtils.showMyToast(toast, 3000);
            }
        }, TAG);
    }

    //地图中选择地址后返回的信息，添加到接口中获取数据操作
    @Subscriber(tag = "e-searchlocation")
    private void getCondItion(PoiItemBean mAskBean) {
        mTvOrderFormLocation.setText(mAskBean.getTitle());
        mIsMapGaoDe = false;
        List<PoiItemBean> msearListBean = new ArrayList<PoiItemBean>();
        PoiItemBean headBean = new PoiItemBean();
        headBean.setLatitude(mAskBean.getLatitude());
        headBean.setLongitude(mAskBean.getLongitude());
        headBean.setCitycode(mAskBean.getCitycode());
        headBean.setTitle(mAskBean.getTitle());
        msearListBean.add(headBean);
        dataSave.setDataList(QR_LOCATION, msearListBean);//保存数据
        cleaningLocation(mAskBean.getLatitude(),mAskBean.getLongitude());
        if (mListBean != null) {
            mListBean.clear();
        }else{
            mListBean=new ArrayList<>();
        }
        mListBean.add(headBean);
        mTvOrderFromPeriphery.setTextColor(Color.parseColor("#3DB64D"));
        mTvOrderFromPeripheryView.setVisibility(View.VISIBLE);
        mTvOrderFromInsideCity.setTextColor(Color.parseColor("#999999"));
        mTvOrderFromInsideCityView.setVisibility(View.GONE);
        mTypeStatus = 1;
        mNoData = true;
        isErr = true;
        mIslazy=false;
    }

    //保洁员接单位置上传，只有在APP第一次启动的时候保存一次，地图选择位置返回时替换位置
    public void cleaningLocation(double Latitude,double Longitude){
        Log.w("oushuhua","LOCATION");
        Params params = new Params();
        params.add("lat", Latitude);
        params.add("lon", Longitude);
        AuzHttp.get(UrlPool.UPDATE_LOCATION, params, new DataJson_Cb() {
            @Override
            public void onSuccess(int code, String data) {

            }

            @Override
            public void onFailure(int errorCode, String msg) {

            }
        }, "");
    }

    @Override
    public void onResume() {
        super.onResume();
        Log.i(TAG,"onResume()");
        if (TextUtils.isEmpty(LocationGaoDe.getAddress())) {
            new LocationGaoDe().init(getActivity());
            LocationGaoDe.startLocation();
            mRouteSearch = new RouteSearch(mBaseContext);
            mRouteSearch.setRouteSearchListener(this);
            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {

                    initView();
                    mAdapter.setEmptyView(R.layout.loading_view, (ViewGroup) mRvOrderFromList.getParent());
                    Refresh();
                }
            }, 1000);
        } else {
            mRouteSearch = new RouteSearch(mBaseContext);
            mRouteSearch.setRouteSearchListener(this);
            initView();
            mAdapter.setEmptyView(R.layout.loading_view, (ViewGroup) mRvOrderFromList.getParent());
            Refresh();
        }
        mNoData=true;
    }

    @Override
    public void onPause() {
        super.onPause();
    }

    public void setData(boolean isRefresh, List data) {
        mPageIndex++;
        final int size = data == null ? 0 : data.size();
        if (isRefresh) {
            if (data == null || data.size() == 0) {
                mNoData = false;
                mSrlFgOrderFormList.setEnabled(false);
                if (mAdapter.getData().size() > 0) {
                    mAdapter.getData().clear();
                }
                mAdapter.setEmptyView(notDataView);
                mAdapter.notifyDataSetChanged();
            } else {
                mSrlFgOrderFormList.setEnabled(true);
                if (mAdapter.getData().size() > 0) {
                    mAdapter.getData().clear();
                }
                mAdapter.setNewData(data);
            }
        } else {
            if (size > 0) {
                mAdapter.addData(data);
            }
        }
        mCurrentCounter = mAdapter.getData().size();
        if (size < PAGE_SIZE) {
            //第一页如果不够一页就不显示没有更多数据布局
            mAdapter.loadMoreEnd(isRefresh);
        } else {
            mAdapter.loadMoreComplete();
        }
    }


    protected boolean isPermissionGranted(String permissionName, int questCode) {
        //6.0以下系统，取消请求权限
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
            return true;
        }
        //判断是否需要请求允许权限，否则请求用户授权
        int hasPermision = mBaseContext.checkSelfPermission(permissionName);
        if (hasPermision != PackageManager.PERMISSION_GRANTED) {
            requestPermissions(new String[]{permissionName}, questCode);
            return false;
        }
        return true;
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        if (grantResults.length == 0) {
            return;
        }
        switch (requestCode) {
            case Constants.QUEST_CODE_LOCTION:
                if (grantResults[0] != PackageManager.PERMISSION_GRANTED) {
                    AlterLocation.popAlterDialog(mBaseContext, "定位服务已关闭", "请到设置->定位服务中开启[快洁帮专员]定位服务，以便能够准确获得您的位置");
                }
                break;
            default:
                super.onRequestPermissionsResult(requestCode, permissions,
                        grantResults);
                break;
        }
    }

    @Override
    public void onBusRouteSearched(BusRouteResult busRouteResult, int i) {

    }

    @Override
    public void onDriveRouteSearched(DriveRouteResult driveRouteResult, int i) {

    }

    @Override
    public void onWalkRouteSearched(WalkRouteResult walkRouteResult, int i) {

    }

    @Override
    public void onRideRouteSearched(RideRouteResult rideRouteResult, int i) {
        if (i == 1000) {
            RidePath ridePath = rideRouteResult.getPaths().get(0);
            //setRideRoute(ridePath, rideRouteResult.getStartPos(), rideRouteResult.getTargetPos());
            float distance = ridePath.getDistance() / 1000;
            long duration = ridePath.getDuration() / 60;
            mrecords.get(mrecordsPosition).setRideDistance(distance);
            mrecords.get(mrecordsPosition).setRideDuration(duration);
            Log.i(TAG, "onRideRouteSearched ==> " + mrecordsPosition + " 距离/公里：" + distance + " 时间/分：" + duration + " getRideDistance = " + mrecords.get(mrecordsPosition).getRideDistance());
            mrecordsPosition++;
            setRideData(mrecordsPosition);
            if (mrecordsPosition == mrecords.size()) {
                mrecordsPosition = 0;
            }

        } else {
            Log.i(TAG, "onRideRouteSearched: 路线规划失败");
        }
    }


    private void setRideData(int position){

            if (position<mrecords.size()){
                RouteSearch.FromAndTo fromAndTo = new RouteSearch.FromAndTo(
                        new LatLonPoint(LocationGaoDe.getLatitude(),LocationGaoDe.getLongitude()),
                        new LatLonPoint(Double.valueOf(mrecords.get(position).getLat()), Double.valueOf(mrecords.get(position).getLon())));
                RouteSearch.RideRouteQuery query = new RouteSearch.RideRouteQuery(
                        fromAndTo, RouteSearch.RIDING_DEFAULT);
                mRouteSearch.calculateRideRouteAsyn(query);
            }else{
                if (mPageIndex == 1) {
                    setData(true, mrecords);
                } else {
                    setData(false, mrecords);
                }
            }
    }

    @Override
    protected void hiddenChange(boolean hidden) {
        super.hiddenChange(hidden);
        isVisiableOrder = hidden;
        Log.i(TAG,"hiddenChange ==> hidden = "+hidden);
    }
}
